package top.topsmart.api.bycenter.config;

import org.springframework.boot.web.servlet.MultipartConfigFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.util.unit.DataSize;

import javax.servlet.MultipartConfigElement;

@Configuration
public class UploadConfig {
    @Bean
    public MultipartConfigElement multipartConfigElement(){
        MultipartConfigFactory factory = new MultipartConfigFactory();
        // 设置文件大小限制 ,超出设置页面会抛出异常信息
        factory.setMaxFileSize(DataSize.parse("10240KB"));
        //设置总上传文件大小
        factory.setMaxRequestSize(DataSize.parse("10240KB"));
        return factory.createMultipartConfig();
    }
}


